package com.sakura.system.dao.jrjdao;

import com.sakura.system.entity.jrj.News;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 操作news相关数据接口
 */

@Repository
@Mapper
public interface NewsMapper {

    /**
     * 新增
     */
    int insert(News news);

    /**
     * 删除
     */
    int deleteById(Integer id);

    /**
     * 修改
     */
    int updateById(News news);

    /**
     * 根据ID查询
     */
    News selectById(Integer id);

    /**
     * 查询所有
     */
    List<News> selectAll(News news);


    List<News> getSelectAll(News news);



    @Select("select * from news order by read_count desc")
    List<News> selectHot();

    @Update("update news set read_count = read_count + 1 where id = #{id}")
    void updateCount(Integer id);
}